package com.situ.mall.base.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Objects;

/**
 * ClassName: RequestUtil
 * Package: com.situ.mall.base.util
 * Description:
 *
 * @Author Darling_达
 * @Create 2023-04-02 21:32
 * @Version 1.0
 */
public class RequestUtil {

    // 调用  此静态方法直接返回当前这次请求的 request 对象
    public static HttpServletRequest getRequest(){
        return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
    }

    public static HttpSession getSession() {
        return getRequest().getSession();
    }


}
